<?php
/**
@Project: 
@Page: 
@Path: 
@Notes: 
**/
class SHML_User
{

	public function user_access($properties)
	{
		if (!isset($properties['var_list']['user_access'])) {
			return "<!--The 'access' variable is not set therefore cannot be used.-->";
		}
	
		$v = strtolower($properties['attributes']['value']);
		$list = explode(",", $properties['var_list']['user_access']);
		$found = FALSE;
		
		foreach ($list as $level) {
			if (strtolower($v) == trim(strtolower($level))) {
				$found = TRUE;
			}
		}
		
		return ($found === TRUE) ? $properties['innerHTML'] : "";
	}
	
	public function user_activated($properties)
	{
		$v = (strtolower($properties['attributes']['value']) == "true") ? TRUE : FALSE;
		$a = (strtolower($properties['var_list']['user_activated']) == "true" || $properties['var_list']['user_activated'] === TRUE) ? TRUE : FALSE;
		
		if (($v && $a) || (!$v && !$a)) {
			return $properties['innerHTML'];
		}
		else {
			return "";
		}
	}
	
	public function user_logged_in($properties)
	{
		$v = (strtolower($properties['attributes']['value']) == "true") ? TRUE : FALSE;
		$l = (strtolower($properties['var_list']['user_logged_in']) == "true" || $properties['var_list']['user_logged_in'] === TRUE) ? TRUE : FALSE;
		
		if (($v && $l) || (!$v && !$l)) {
			return $properties['innerHTML'];
		}
		else {
			return "";
		}
	}
	
}